package com.atguigu.tingshu.user.api;


import com.atguigu.tingshu.common.result.Result;
import com.atguigu.tingshu.common.util.AuthContextHolder;
import com.atguigu.tingshu.user.service.UserInfoService;
import com.atguigu.tingshu.vo.user.UserInfoVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@Tag(name = "用户管理接口")
@RestController
@RequestMapping("/api/user/userInfo")
@SuppressWarnings({"all"})
public class UserInfoApiController {

	@Autowired
	private UserInfoService userInfoService;


	@Operation(summary = "根据用户Id获取到用户信息")
	@GetMapping("/getUserInfoVo/{userId}")
	public Result<UserInfoVo> getUserInfo(@PathVariable Long userId) {
		UserInfoVo userInfoVo = userInfoService.getUserInfo(userId);
		return Result.ok(userInfoVo);
	}

	@Operation(summary = "根据专辑id查询用户是否购买声音列表")
	@GetMapping("/userIsPaidTrack/{albumId}")
	public Result<Map<Long,Integer>> userIsPaidTrack(@PathVariable Long albumId, @RequestBody List<Long> needPaidTrackIdList ) {
		Long userId = AuthContextHolder.getUserId();
		Map<Long,Integer> map	=userInfoService.userIsPaidTrack(albumId, userId, needPaidTrackIdList);
		return Result.ok(map);
	}
}

